package com.zjxf.controller;

import com.zjxf.base.common.JSONResponse;
import com.zjxf.base.common.OperationException;
import com.zjxf.controller.common.BaseController;
import com.zjxf.service.AppService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * created with IntelliJ IDEA
 *
 * @author: create by limu
 * Date: 2021/4/6
 * Time：15:14
 */
@Api(tags = "app应用接口")
@AllArgsConstructor
@RestController
@Validated
@RequestMapping(value = "/app/mobile ")
public class AppController extends BaseController {

    public final AppService appService;

    /**
     * 通过高德定位信息获取区县id
     *
     * @param locationStr 高德定位信息
     * @return JSONResponse 区县id
     * @throws OperationException 位置信息不合法
     */
    @PostMapping("getRegionByStr")
    public JSONResponse getRegionByStr(@NotNull String locationStr) throws OperationException {
        Long regionId = appService.getRegionByStr(locationStr);
        return success(regionId);
    }
}
